package com.coship.vasms.adstorm.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.coship.vasms.adstorm.dao.ArrangeNotifyDao;
import com.coship.vasms.adstorm.model.Arrangenotify;
import com.coship.vasms.adstorm.webservice.advertise.vo.ArrangDisplay;

public class ArrangeNotifyDaoImpl implements ArrangeNotifyDao{
	private SqlMapClientTemplate sqlMapClientTemplate;
	
	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}
	
	/**
	 * 插入新的通知记录
	 * @param log
	 */
	public void save(Arrangenotify notify){
		sqlMapClientTemplate.insert("insert", notify);
	}
	
	/**
	 * 停播通知后，修改通知结果状态
	 */
	@Override
	public void update(Arrangenotify notify){
		sqlMapClientTemplate.update("update", notify);
	}
	
	/**
	 * 播放通知查询列表
	 */
	@Override
	public List<ArrangDisplay> queryPlayReq(String date, Integer pageStart, Integer pageSize) {
		Map map = new HashMap();
		map.put("starttime1", date);
		map.put("pageStart", pageStart);
		map.put("pageSize", pageSize);
		return sqlMapClientTemplate.queryForList("queryPlayReq", map);
	}

	/**
	 * 播放通知失败列表
	 */
	@Override
	public List<ArrangDisplay> queryPlayNotifyFail(String date, Integer number, Integer pageStart, Integer pageSize) {
		Map map = new HashMap();
		map.put("startNumber", number);
		map.put("starttime1", date);
		map.put("pageStart", pageStart);
		map.put("pageSize", pageSize);
		return sqlMapClientTemplate.queryForList("queryPlayNotifyFail", map);
	}

	/**
	 * 获取通知历史对象
	 */
	@Override
	public Arrangenotify queryByid(Integer id) {
		return (Arrangenotify)sqlMapClientTemplate.queryForObject("queryByid", id);
	}

	/**
	 * 停播通知查询列表
	 */
	@Override
	public List<ArrangDisplay> queryDisplayReq(String date, Integer pageStart, Integer pageSize) {
		Map map = new HashMap();
		map.put("endtime1", date);
		map.put("pageStart", pageStart);
		map.put("pageSize", pageSize);
		return sqlMapClientTemplate.queryForList("queryDisplayReq", map);
	}

	/**
	 * 停播通知失败列表
	 */
	@Override
	public List<ArrangDisplay> queryDisplayNotifyFail(String date,
			Integer number , Integer pageStart, Integer pageSize) {
		Map map = new HashMap();
		map.put("stopNumber", number);
		map.put("endtime1", date);
		map.put("pageStart", pageStart);
		map.put("pageSize", pageSize);
		return sqlMapClientTemplate.queryForList("queryDisplayNotifyFail", map);
	}

	@Override
	public Integer countDisplay(String date) {
		Map map = new HashMap();
		map.put("endtime1", date);
		return (Integer)sqlMapClientTemplate.queryForObject("countDisplay", map);
	}

	@Override
	public Integer countPlay(String date) {
		Map map = new HashMap();
		map.put("starttime1", date);
		return (Integer)sqlMapClientTemplate.queryForObject("countPlay", map);
	}

	
	

}
